package com.greenlife.commom;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.springframework.data.domain.Sort;

/**
 * 分页对象
 * 
 * @author peitong.xue
 * @version 1.0
 * @since 1.0 2015年11月21日 下午11:43:37
 */
public class PageInfo extends ToString {

	/** serialVersionUID */
	private static final long serialVersionUID = -1213662953102038221L;

	/** 当前页码 */
	private int curPage;

	/** 记录总数 */
	private long items;

	/** 总页数 */
	private long totalPage;

	/** 每页项数 */
	private int itemsPerPage;

	/** 第一条记录的位置 */
	private int offset;

	/** 当前返回多少条 */
	private int curItems;

	/** 封装排序信息 */
	private Sort sort;

	public int getCurPage() {
		return curPage;
	}

	public void setCurPage(int curPage) {
		if (curPage <= 0) {
			curPage = 1;
		}
		this.curPage = curPage;
	}

	public long getItems() {
		return items;
	}

	public void setItems(long items) {
		this.items = items;
	}

	public long getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(long totalPage) {
		this.totalPage = totalPage;
	}

	public int getItemsPerPage() {
		return itemsPerPage;
	}

	public void setItemsPerPage(int itemsPerPage) {
		this.itemsPerPage = itemsPerPage;
	}

	@JsonIgnore
	public Sort getSort() {
		return sort;
	}

	public void setSort(Sort sort) {
		this.sort = sort;
	}

	@JsonIgnore
	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getCurItems() {
		return curItems;
	}

	public void setCurItems(int curItems) {
		this.curItems = curItems;
	}

	public PageInfo() {
		this.curPage = 1;
		this.itemsPerPage = 10;
	}

}
